package inventory.view;

import java.awt.Component;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SpringLayout;
import javax.swing.SwingConstants;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import java.awt.Dimension;
import javax.swing.DefaultComboBoxModel;

public class CategoryManagment extends JPanel{
	private JRadioButton rdbtnActive;
	private JTextField editTfNewname;
	private JComboBox editCbName;
	private JTextField addTfName;
	private JButton btnUpdate;
	private JButton addBtnAdd;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JRadioButton rdbtnInactive;
	
	CategoryManagment()
	{	
		SpringLayout sl_this = new SpringLayout();
		this.setLayout(sl_this);
		
		JPanel panel_5 = new JPanel();
		sl_this.putConstraint(SpringLayout.NORTH, panel_5, 10, SpringLayout.NORTH, this);
		sl_this.putConstraint(SpringLayout.WEST, panel_5, 10, SpringLayout.WEST, this);
		sl_this.putConstraint(SpringLayout.SOUTH, panel_5, -9, SpringLayout.SOUTH, this);
		sl_this.putConstraint(SpringLayout.EAST, panel_5, -15, SpringLayout.EAST, this);
		this.add(panel_5);
		SpringLayout sl_panel_5 = new SpringLayout();
		panel_5.setLayout(sl_panel_5);
		
		JLabel lblAddCategory = new JLabel("Add Category ");
		sl_panel_5.putConstraint(SpringLayout.NORTH, lblAddCategory, 10, SpringLayout.NORTH, panel_5);
		sl_panel_5.putConstraint(SpringLayout.WEST, lblAddCategory, 10, SpringLayout.WEST, panel_5);
		panel_5.add(lblAddCategory);
		
		JLabel lblName = new JLabel("Name");
		sl_panel_5.putConstraint(SpringLayout.NORTH, lblName, 36, SpringLayout.NORTH, panel_5);
		sl_panel_5.putConstraint(SpringLayout.WEST, lblName, 130, SpringLayout.WEST, panel_5);
		panel_5.add(lblName);
		
		addTfName = new JTextField();
		sl_panel_5.putConstraint(SpringLayout.NORTH, addTfName, 36, SpringLayout.NORTH, panel_5);
		sl_panel_5.putConstraint(SpringLayout.WEST, addTfName, 6, SpringLayout.EAST, lblName);
		sl_panel_5.putConstraint(SpringLayout.EAST, addTfName, 138, SpringLayout.EAST, lblName);
		panel_5.add(addTfName);
		addTfName.setColumns(10);
		
		JLabel lblEditCategory = new JLabel("Edit Category ");
		sl_panel_5.putConstraint(SpringLayout.NORTH, lblEditCategory, 58, SpringLayout.SOUTH, lblAddCategory);
		sl_panel_5.putConstraint(SpringLayout.WEST, lblEditCategory, 0, SpringLayout.WEST, lblAddCategory);
		panel_5.add(lblEditCategory);
		
		JLabel lblName_1 = new JLabel("Name");
		sl_panel_5.putConstraint(SpringLayout.WEST, lblName_1, 0, SpringLayout.WEST, lblName);
		panel_5.add(lblName_1);
		
		 editCbName = new JComboBox();
		 sl_panel_5.putConstraint(SpringLayout.SOUTH, editCbName, -316, SpringLayout.SOUTH, panel_5);
		 editCbName.setPreferredSize(new Dimension(200, 23));
		sl_panel_5.putConstraint(SpringLayout.WEST, editCbName, 17, SpringLayout.EAST, lblName_1);
		
		panel_5.add(editCbName);
		
		JLabel lblNewName = new JLabel("New Name");
		sl_panel_5.putConstraint(SpringLayout.NORTH, lblNewName, 169, SpringLayout.NORTH, panel_5);
		sl_panel_5.putConstraint(SpringLayout.SOUTH, lblName_1, -18, SpringLayout.NORTH, lblNewName);
		sl_panel_5.putConstraint(SpringLayout.EAST, lblNewName, 0, SpringLayout.EAST, lblName);
		panel_5.add(lblNewName);
		
		editTfNewname = new JTextField();
		sl_panel_5.putConstraint(SpringLayout.NORTH, editTfNewname, 6, SpringLayout.SOUTH, editCbName);
		sl_panel_5.putConstraint(SpringLayout.WEST, editTfNewname, 0, SpringLayout.WEST, addTfName);
		
		panel_5.add(editTfNewname);
		editTfNewname.setColumns(15);
		
		JLabel lblActive = new JLabel("ACTIVE :");
		sl_panel_5.putConstraint(SpringLayout.NORTH, lblActive, 17, SpringLayout.SOUTH, lblNewName);
		sl_panel_5.putConstraint(SpringLayout.WEST, lblActive, 0, SpringLayout.WEST, lblNewName);
		panel_5.add(lblActive);
		
		rdbtnActive = new JRadioButton("Active");
		sl_panel_5.putConstraint(SpringLayout.NORTH, rdbtnActive, 12, SpringLayout.SOUTH, editTfNewname);
		sl_panel_5.putConstraint(SpringLayout.WEST, rdbtnActive, 0, SpringLayout.WEST, editCbName);
		buttonGroup.add(rdbtnActive);
		panel_5.add(rdbtnActive);
		
		addBtnAdd = new JButton("Add");
		sl_panel_5.putConstraint(SpringLayout.NORTH, addBtnAdd, -4, SpringLayout.NORTH, lblName);
		sl_panel_5.putConstraint(SpringLayout.WEST, addBtnAdd, 14, SpringLayout.EAST, addTfName);
		panel_5.add(addBtnAdd);
		addBtnAdd.setActionCommand("add");
		
		btnUpdate = new JButton("Update");
		sl_panel_5.putConstraint(SpringLayout.NORTH, btnUpdate, 12, SpringLayout.SOUTH, rdbtnActive);
		sl_panel_5.putConstraint(SpringLayout.WEST, btnUpdate, 0, SpringLayout.WEST, addTfName);
		panel_5.add(btnUpdate);
		addBtnAdd.setActionCommand("update");
		
		rdbtnInactive = new JRadioButton("Inactive");
		sl_panel_5.putConstraint(SpringLayout.NORTH, rdbtnInactive, 12, SpringLayout.SOUTH, editTfNewname);
		buttonGroup.add(rdbtnInactive);
		sl_panel_5.putConstraint(SpringLayout.EAST, rdbtnInactive, 0, SpringLayout.EAST, editCbName);
		panel_5.add(rdbtnInactive);
		
		
		
	}

	
	public JTextField getEditTfNewname() {
		return editTfNewname;
	}

	public void setEditTfNewname(JTextField editTfNewname) {
		this.editTfNewname = editTfNewname;
	}


	public JTextField getAddTfName() {
		return addTfName;
	}

	public void setAddTfName(JTextField addTfName) {
		this.addTfName = addTfName;
	}

	public JButton getBtnUpdate() {
		return btnUpdate;
	}

	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}
	
	public JRadioButton getRdbtnActive() {
		return rdbtnActive;
	}


	public void setRdbtnActive(JRadioButton rdbtnActive) {
		this.rdbtnActive = rdbtnActive;
	}


	public JRadioButton getRdbtnInactive() {
		return rdbtnInactive;
	}


	public void setRdbtnInactive(JRadioButton rdbtnInactive) {
		this.rdbtnInactive = rdbtnInactive;
	}


	public JComboBox getEditCbName() {
		return editCbName;
	}


	public void setEditCbName(JComboBox editCbName) {
		this.editCbName = editCbName;
	}


	public void setActionlistener(ActionListener al)
	{
		btnUpdate.addActionListener(al);
		addBtnAdd.addActionListener(al);
	}
}
